<html>
<head><meta charset="utf-8"><title>Support Rvalue::{Ref,Len} and Deref #61532 · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html">Support Rvalue::{Ref,Len} and Deref #61532</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="167475035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475035">(Jun 06 2019 at 12:05)</a>:</h4>
<p>I'm trying to track down the ICE that lead me to add <a href="https://github.com/rust-lang/rust/pull/61532/commits/5be005df9876ff191cc9e193bc3fb5bb1f972424" target="_blank" title="https://github.com/rust-lang/rust/pull/61532/commits/5be005df9876ff191cc9e193bc3fb5bb1f972424">this change</a>.</p>
<p>The minimal repro is:</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">_</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">main</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="kt">usize</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>which ICEs with:</p>
<div class="codehilite"><pre><span></span>thread &#39;rustc&#39; panicked at &#39;value should already be a valid const: EvalError { kind: type validation failed: encountered a pointer, but expected initialized plain (non-pointer) bytes, backtrace: None }&#39;, src/libcore/result.rs:999:5
stack backtrace:
   0: std::sys_common::backtrace::print
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: rustc::util::common::panic_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::continue_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::result::unwrap_failed
   9: &lt;rustc_mir::transform::const_prop::ConstPropagator as rustc::mir::visit::MutVisitor&gt;::visit_statement
  10: rustc::mir::visit::MutVisitor::visit_body
  11: &lt;rustc_mir::transform::const_prop::ConstProp as rustc_mir::transform::MirPass&gt;::run_pass
</pre></div>


<p>I noticed in the call <a href="https://github.com/rust-lang/rust/blob/daf1ed0e98e75c64c3b883fd845b37bfa42358de/src/librustc_mir/transform/const_prop.rs#L532" target="_blank" title="https://github.com/rust-lang/rust/blob/daf1ed0e98e75c64c3b883fd845b37bfa42358de/src/librustc_mir/transform/const_prop.rs#L532">here</a> to <code>validate_operand()</code>, we pass <code>const_mode: true</code> but in <code>InterpretCtx::write_immediate()</code> we <a href="https://github.com/rust-lang/rust/blob/daf1ed0e98e75c64c3b883fd845b37bfa42358de/src/librustc_mir/interpret/place.rs#L660" target="_blank" title="https://github.com/rust-lang/rust/blob/daf1ed0e98e75c64c3b883fd845b37bfa42358de/src/librustc_mir/interpret/place.rs#L660">pass false</a>.</p>
<p>Should we be passing <code>true</code> or <code>false</code> in const prop? (If  I pass <code>false</code>, the ICE goes away and the program seems to compile fine.)</p>



<a name="167475182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475182">(Jun 06 2019 at 12:07)</a>:</h4>
<p>I think we should just turn the <code>expect</code> into <code>.ok()?</code></p>



<a name="167475202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475202">(Jun 06 2019 at 12:07)</a>:</h4>
<p>That would work too</p>



<a name="167475220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475220">(Jun 06 2019 at 12:08)</a>:</h4>
<p>we can't really promise that const prop won't end up in some way emitting a constant that doesn't pass the validity checks</p>



<a name="167475273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475273">(Jun 06 2019 at 12:08)</a>:</h4>
<p>while we could probably allow that, let's stay conservative</p>



<a name="167475324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475324">(Jun 06 2019 at 12:08)</a>:</h4>
<p>Are we concerned that a Const that does't validate has already been put into <code>self.places[local]</code>?</p>



<a name="167475352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475352">(Jun 06 2019 at 12:09)</a>:</h4>
<p>Ie, we might try to use that value when we go to const prop again in a later statement</p>



<a name="167475364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475364">(Jun 06 2019 at 12:09)</a>:</h4>
<p>yes, and I believe it's perfectly alright to have them in <code>self.places</code>, just not in <code>mir::Body</code></p>



<a name="167475367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475367">(Jun 06 2019 at 12:09)</a>:</h4>
<p>Ok</p>



<a name="167475457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475457">(Jun 06 2019 at 12:10)</a>:</h4>
<p>I'l change that first commit as you suggest. I'm going to leave the test in though since it was ICE-ing before</p>



<a name="167475478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475478">(Jun 06 2019 at 12:10)</a>:</h4>
<p>you could have <code>main as usize as fn()</code> and the first <code>_1 = main</code> is ok, the <code>_2 = _1 as usize</code> will not get changed and the <code>_3 = _2 as fn()</code> will get replaced by <code>_3 = some_constant_pointer_to_main</code></p>



<a name="167475488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475488">(Jun 06 2019 at 12:10)</a>:</h4>
<p>yes, leave the test in, regression tests are important</p>



<a name="167475506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475506">(Jun 06 2019 at 12:11)</a>:</h4>
<p>Ok, I'll do that</p>



<a name="167475524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475524">(Jun 06 2019 at 12:11)</a>:</h4>
<p>Do you think the performance measurement needs to be done before landing the PR?</p>



<a name="167475749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475749">(Jun 06 2019 at 12:14)</a>:</h4>
<p>you mean about my <code>measureme</code> comment?</p>



<a name="167475863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167475863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167475863">(Jun 06 2019 at 12:16)</a>:</h4>
<p>Yeah</p>



<a name="167476340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167476340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167476340">(Jun 06 2019 at 12:23)</a>:</h4>
<p>hm. I don't really know if we have an official policy. You can open an issue with all info needed to repro (commit ids and link to the perf run) and assign it to me. I'll see if I can setup something to run these things conveniently (I really just want to be like <code>measureme_helper.sh commit_id_1 commit_id_2</code> in some folder with a <code>Cargo.toml</code> and get output</p>



<a name="167476442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167476442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167476442">(Jun 06 2019 at 12:24)</a>:</h4>
<p>There's a open issue on <code>measureme</code> to add a built-in diff mode. Maybe I just need to go do that first <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="167476603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167476603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167476603">(Jun 06 2019 at 12:27)</a>:</h4>
<p>oh right, in this case, if we wait for the PR to get merged, we can download the rustcs via <code>rustup-toolchain-master</code></p>



<a name="167476617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167476617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167476617">(Jun 06 2019 at 12:27)</a>:</h4>
<p>I was thinking we'd have to build both versions</p>



<a name="167476707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167476707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167476707">(Jun 06 2019 at 12:28)</a>:</h4>
<p>Yeah, that's true</p>



<a name="167476949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167476949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167476949">(Jun 06 2019 at 12:32)</a>:</h4>
<p>so I guess r=me with the cast bailout replaced by a validation bailout</p>



<a name="167481976"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167481976" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167481976">(Jun 06 2019 at 13:37)</a>:</h4>
<p>It looks like these changes cause some new const eval warnings to appear:</p>
<div class="codehilite"><pre><span></span>[01:00:06] ---- [ui] ui/consts/const-eval/promoted_errors.rs stdout ----
[01:00:06] diff of stderr:
[01:00:06]
[01:00:06] 16 LL |     println!(&quot;{}&quot;, 1/(1-1));
[01:00:06] 18
[01:00:06] + warning: this expression will panic at runtime
[01:00:06] +   --&gt; $DIR/promoted_errors.rs:9:20
[01:00:06] +    |
[01:00:06] +    |
[01:00:06] + LL |     println!(&quot;{}&quot;, 1/(1-1));
[01:00:06] +
[01:00:06] 19 warning: attempt to divide by zero
[01:00:06] 20   --&gt; $DIR/promoted_errors.rs:11:14
[01:00:06] 21    |
[01:00:06] 21    |
[01:00:06]
[01:00:06] 33    |
[01:00:06] 34 LL |     println!(&quot;{}&quot;, 1/(false as u32));
[01:00:06] +
[01:00:06] + warning: this expression will panic at runtime
[01:00:06] +   --&gt; $DIR/promoted_errors.rs:14:20
[01:00:06] +    |
[01:00:06] +    |
[01:00:06] + LL |     println!(&quot;{}&quot;, 1/(false as u32));
[01:00:06] 36
</pre></div>


<p>Is that ok or is that a backwards compatibility issue?</p>



<a name="167488640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167488640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167488640">(Jun 06 2019 at 14:52)</a>:</h4>
<blockquote>
<p>we can't really promise that const prop won't end up in some way emitting a constant that doesn't pass the validity checks</p>
</blockquote>
<p><span class="user-mention" data-user-id="124288">@oli</span>  This sounds like an optimization taking valid code and making it into invalid code...? That sounds like it violates type preservation to me ==&gt; soundness hole.</p>



<a name="167488739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167488739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167488739">(Jun 06 2019 at 14:53)</a>:</h4>
<p>uhm... the validity checks are there exactly to prevent that ;)</p>



<a name="167488762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167488762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167488762">(Jun 06 2019 at 14:53)</a>:</h4>
<p>we don't prop if the constant would be invalid</p>



<a name="167488866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167488866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167488866">(Jun 06 2019 at 14:54)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> so hmm; you take known-to-be-valid code and const prop on it and that may yield invalid code?</p>



<a name="167488871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167488871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167488871">(Jun 06 2019 at 14:54)</a>:</h4>
<p>that is later rejected...?</p>



<a name="167488897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167488897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167488897">(Jun 06 2019 at 14:55)</a>:</h4>
<p>heh well. <code>main as usize</code> is const-invalid</p>



<a name="167488911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167488911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167488911">(Jun 06 2019 at 14:55)</a>:</h4>
<p>so we don't const prop that</p>



<a name="167489047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167489047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167489047">(Jun 06 2019 at 14:56)</a>:</h4>
<p>Idk if that answers my question =P</p>



<a name="167489103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167489103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167489103">(Jun 06 2019 at 14:57)</a>:</h4>
<p>well. we prop known-to-be-valid code and durin const prop realize it's not const-valid, so we throw it away</p>



<a name="167489543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167489543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167489543">(Jun 06 2019 at 15:01)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span>  ah, but you don't cause a compile time error?</p>



<a name="167489555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167489555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167489555">(Jun 06 2019 at 15:01)</a>:</h4>
<p>no</p>



<a name="167489565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167489565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167489565">(Jun 06 2019 at 15:01)</a>:</h4>
<p>we just silently do nothing</p>



<a name="167489574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167489574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167489574">(Jun 06 2019 at 15:01)</a>:</h4>
<p><span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span>  so not a soundness issue</p>



<a name="167489584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167489584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167489584">(Jun 06 2019 at 15:01)</a>:</h4>
<p>optimizations can be opportunistic like that :D</p>



<a name="167489603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167489603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167489603">(Jun 06 2019 at 15:01)</a>:</h4>
<p>we may emit warnings if we encounter wrong code though</p>



<a name="167489701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167489701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167489701">(Jun 06 2019 at 15:02)</a>:</h4>
<p>Such as those <span aria-label="up" class="emoji emoji-2b06" role="img" title="up">:up:</span> <span aria-label="up" class="emoji emoji-2b06" role="img" title="up">:up:</span> <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="167489847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167489847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167489847">(Jun 06 2019 at 15:04)</a>:</h4>
<p>So I guess new warnings are ok then?</p>



<a name="167489913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167489913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167489913">(Jun 06 2019 at 15:05)</a>:</h4>
<p>Do we need to worry about people with <code>#[deny(warnings)]</code>?</p>



<a name="167490052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167490052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167490052">(Jun 06 2019 at 15:06)</a>:</h4>
<p>nope</p>



<a name="167490063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167490063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167490063">(Jun 06 2019 at 15:06)</a>:</h4>
<p>we can have as many new warnings as we want</p>



<a name="167490070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167490070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167490070">(Jun 06 2019 at 15:06)</a>:</h4>
<p>I even have an accepted RFC for that</p>



<a name="167490077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167490077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167490077">(Jun 06 2019 at 15:06)</a>:</h4>
<p>1229</p>



<a name="167490171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Support%20Rvalue%3A%3A%7BRef%2CLen%7D%20and%20Deref%20%2361532/near/167490171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Support.20Rvalue.3A.3A.7BRef.2CLen.7D.20and.20Deref.20.2361532.html#167490171">(Jun 06 2019 at 15:08)</a>:</h4>
<p>Ok. I'll bless the tests tonight when I get home and then <code>r=you</code>. I already made the cast -&gt; validation ballout and test change we discussed.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>